<template>
	<view class="content">
		<view class="sort" v-if="ticketList.length>0">
			排序
			<image class="arrow_down" :src="IMGLink+'/my/arrow-down-outline.png'" mode="widthFix"></image>
		</view>
		<scroll-view scroll-y="true" class="scroll-Y" :scroll-y="true" :refresher-enabled="true"
			:refresher-threshold="45" refresher-background="#EFF0F1" @refresherrefresh="onRefresh"
			:refresher-triggered="refresh">
			<view class="fanslist">
				<view class="fans_one" v-for="(item,index) in ticketList" :key="index" @click="deepC(item.user_id)">
					<view class="fans_one_left">
						<image class="user_img" :src="item.img" mode="widthFix"></image>
						<view class="userinfo">
							<view>{{item.nickname}}</view>
							<text class="type">{{item.type}}</text>
						</view>
					</view>
					<view class="fans_one_right">
						<text style="line-height: 48rpx;">{{item.user_level_id}}</text>
						<view class="create_time">
							{{item.create_date}}
						</view>
					</view>
				</view>

				<view v-show="isLoadMore && ticketList.length >0">
					<!-- <uni-load-more :status="loadStatus"></uni-load-more> -->
				</view>

				<view class="nodata" v-if="ticketList.length == 0">
					<image class="empty_img" :src="IMGLink+'/my/empty.png'" mode="widthFix"></image>
					<view>没有你想要的内容</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		addresslist
	} from "@/api/my/address.js";
	export default {
		data() {
			return {
				IMGLink: this.IMGLink,
				ticketList: [],
				page: 1, //页码
				size: '10',
				loadStatus: 'loading', //加载样式：more-加载前样式，loading-加载中样式，nomore-没有数据样式
				isLoadMore: false, //是否加载中
				refresh: false, // 下拉刷新标示
			}
		},
		computed: {
			userinfo() {
				return this.$store.state.userinfo;
			},
		},
		onLoad(options) {
			console.log(options)
		},
		methods: {
			getDataList() {
				uni.showLoading({
					title: '加载中'
				});
				addresslist('getUserFansList', {
					page: this.page,
					page_size: this.size,
					user_id: this.userinfo.id,
				}).then(res => {
					let datas = res.data.list;
			
					this.ticketList = this.page == 1 ? datas : this.ticketList.concat(datas);
					if (datas.length < this.size) { //小于size数，停止请求
						this.isLoadMore = true;
						this.loadStatus = 'nomore';
					} else {
						this.isLoadMore = false;
					}
					uni.hideLoading();
			
					this.refresh = false;
				}).catch(error => {
					uni.hideLoading();
					this.isLoadMore = false;
				})
			},
			onRefresh() {
				this.refresh = true;
				this.page = 1;
				this.getDataList();
			},
			onReachBottom() {
				if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
					this.isLoadMore = true;
					this.page++;
					this.getDataList();
				}
			},
		}
	}
</script>
<style>
	page {
		background-color: #EFF0F1;
	}
</style>
<style lang="scss" scoped>
	@import "../my.scss";

	.content {
		.sort {
			@include flexLayout(center, flext-start);
			line-height: 62rpx;
			color: #717171;
			font-size: 24rpx;
			padding-left: 20rpx;
			padding-top: 16rpx;

			.arrow_down {
				width: 32rpx;
			}
		}

		.fanslist {
			min-height: 100vh;
			
			background-color: #FFFFFF;
			padding: 16rpx 30rpx;
			color: #181818;
			font-size: 24rpx;

			.fans_one {
				@include flexLayout(center, space-between);
				height: 112rpx;
				
				&_left {
					@include flexLayout(center, flex-start);
					color: #181818;
					font-size: 28rpx;
					height: 100%;

					.user_img {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
						margin-right: 12rpx;
					}

					.type {
						line-height: 48rpx;
						color: #626262;
						font-size: 24rpx;
					}
				}

				&_right {
					font-size: 20rpx;
					text-align: right;
					height: 100%;
					display: flex;
					justify-content: space-between;
					flex-direction: column;
					
					.create_time {
						line-height: 48rpx;
					}
				}
			}

			.fans_one:not(:first-child) {
				margin-top: 30rpx;
			}
		}
	}

	.nodata {
		text-align: center;
		color: #7D7D7D;
		font-size: 24rpx;
		margin-top: 50%;

		.empty_img {
			width: 468rpx;
		}
	}
</style>

